﻿@model PotentialRentals.Models.Rental

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Ajax.BeginForm("ConfirmAddress", "Rental", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "#create-rental-content" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Rental</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.Name)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Address.Name)
            @Html.ValidationMessageFor(model => model.Address.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.Street)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Address.Street)
            @Html.ValidationMessageFor(model => model.Address.Street)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.City)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Address.City)
            @Html.ValidationMessageFor(model => model.Address.City)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.State)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Address.State.StateId, ViewBag.States as SelectList)
            @Html.ValidationMessageFor(model => model.Address.State)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address.Zip)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address.Zip)
            @Html.ValidationMessageFor(model => model.Address.Zip)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Rent)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Rent)
            @Html.ValidationMessageFor(model => model.Rent)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Deposit)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Deposit)
            @Html.ValidationMessageFor(model => model.Deposit)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Bedrooms)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Bedrooms)
            @Html.ValidationMessageFor(model => model.Bedrooms)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Bathrooms)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Bathrooms)
            @Html.ValidationMessageFor(model => model.Bathrooms)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Type)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Type.RentTypeId, ViewBag.RentalTypes as SelectList)
            @Html.ValidationMessageFor(model => model.Type)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Amenities)
        </div>
        <div class="editor-field">
            @foreach (var amenity in ViewBag.RentalAmenityList as MultiSelectList)
            {
                <input type="checkbox" name="RentalAmenityList" value="@amenity.Value" /> @amenity.Text<br />
            }
        </div>

        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
